const fetchTemplate = require("../template/download");
const init = require("./baseInit");
const { LOCALSOURCE } = require("../../mfo.config.js");
const { isEmptyObject } = require("../utils");

module.exports = (program) => {
  let _LOCALSOURCE = process.env.LOCALSOURCE || LOCALSOURCE;
  var lang = "english";
  let projectName = program.args[0];
  projectName =
    isEmptyObject(projectName) || projectName === "[object Object]"
      ? "mfoApp"
      : projectName;
  return Promise.resolve()
    .then(() => {
      const context = init(projectName, lang);
      context.source = _LOCALSOURCE;
      lang = context.lang;
      return context;
    })
    .then((context) => {
      return fetchTemplate(context);
    });
};
